package com.slipper.system.sequence;

import javax.annotation.Resource;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.slipper.system.api.sequence.bo.SequenceBO;
import com.slipper.system.api.sequence.service.ISequenceSv;
import com.slipper.system.common.Constants;
import com.slipper.common.util.ResultUtil;

/**
 * @date 2022-05-11 16:41:37
 */
@RestController
@RequestMapping("/sequence")
public class SequenceController {
    @Resource
    private ISequenceSv sequenceSv;
    
    @PostMapping(value = "/queryBy")
    public String queryBy(@RequestBody SequenceBO bo) {
        if(bo.getId() == null || "".equals(bo.getId())) {
            return ResultUtil.toErrorJson("数据获取失败！");
        }
        return ResultUtil.toJson(sequenceSv.queryBy(bo.getId()));
    }
    
    @PostMapping(value = "/queryPage")
    public String queryPage(@RequestBody SequenceBO bo) {
        return ResultUtil.toJson(sequenceSv.queryPage(bo));
    }

    @PostMapping(value = "/save")
    public String save(@RequestBody SequenceBO bo) {
        bo.setUpdateId(Constants.getCurrentUser().getEmployeeId());
        bo.setCreateId(Constants.getCurrentUser().getEmployeeId());
        return ResultUtil.toJson(sequenceSv.save(bo));
    }

    @PostMapping(value = "/delete")
    public String delete(@RequestBody SequenceBO bo) {
        return ResultUtil.toJson(sequenceSv.delete(bo));
    }
}
